﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Leefish.Market.PRO.Utility
{
    /// <summary>
    /// JSON传输结果类
    /// </summary>
    public class Transfers
    {
        private Dictionary<string, object> dict = new Dictionary<string,object>();
        private string _keyNm = "MsgKey";
        private string _contentNm = "MsgContent";

        /// <summary>
        /// 响应消息号
        /// </summary>
        public object MsgKey
        {
            set { dict[_keyNm] = value; }
        }
        /// <summary>
        /// 响应消息内容
        /// </summary>
        public object MsgContent
        {
            set { dict[_contentNm] = value; }
        }

        /// <summary>
        /// 初始化消息响应内容
        /// </summary>
        public Transfers()
        {
            MsgKey = "";
            MsgContent = "";
        }
        /// <summary>
        /// 初始化消息响应内容
        /// </summary>
        /// <param name="key">响应消息号</param>
        /// <param name="content">响应消息内容</param>
        public Transfers(object key, object content)
        {
            MsgKey = key;
            MsgContent = content;
        }

        /// <summary>
        /// 追加响应键值对
        /// </summary>
        /// <param name="key"></param>
        /// <param name="value"></param>
        public void AddColumn(string key, object value)
        {
            dict[key] = value;
        }

        /// <summary>
        /// 结果以JSON格式输出
        /// </summary>
        /// <returns></returns>
        public string ToJson()
        {
            //return JavaScriptConvert.SerializeObject(dict);
            return LitJson.JsonMapper.ToJson(dict);
            
        }
    }
}
